<?php
	$theServer = "scc-sql-1";
	$connectionInfo = array("UID"=>"staff-ulive", "PWD"=>"readonly", "Database"=>"cdf");
	$conn = sqlsrv_connect( $theServer, $connectionInfo);

	$student = $_GET["stu"];
	
	//set the query, adding a ? for a parameter value (referenced in order)
	$query = "exec ip_studentImage ?";
	$query_Params = array($student);

				if( $conn )
				{
				}
				else
				{
				     echo "Connection could not be established.\n";
				     die( print_r( sqlsrv_errors(), true));
				}
				
				//-----------------------------------------------
				// Perform operations with connection.
				//-----------------------------------------------
				
				$runQuery = sqlsrv_query( $conn, $query, $query_Params);
				
				if ($runQuery)
				{
					while ($row = sqlsrv_fetch_array( $runQuery, SQLSRV_FETCH_NUMERIC))
					{
					header("Content-type: image/jpeg;");
					echo $row[0];
					}
				}
				else
				{
					echo("query failed.\n");
					die(print_r(sqlsrv_errors(),true));
				}
?>